package com.cqut.forum.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author yangxun
 * Picture entity
 */
@Entity
@Table(name = "picture", catalog = "forum")
public class Picture implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer pictureId;
	private PictureGroup pictureGroup;
	private Date uploadTime;
	private Integer reviewTimes;
	private Integer visitTimes;
	private String pictureAddress;
	private Boolean isReview;
	private Integer ownerId;
	private Boolean isPublic;
	private Date lastReviewTime;
	private Boolean pictureState;
	/*private Set<PictureVisitLog> pictureVisitLogs = new HashSet<PictureVisitLog>(
			0);*/
	private Set<Review> reviews = new HashSet<Review>(0);

	// Constructors

	/** default constructor */
	public Picture() {
	}

	/** full constructor */
	public Picture(PictureGroup pictureGroup, Date uploadTime,Boolean pictureState,
			Integer reviewTimes, Integer visitTimes, String pictureAddress,
			Boolean isReview, Boolean isPublic,Date lastReviewTime,Integer ownerId,
			/*Set<PictureVisitLog> pictureVisitLogs, */Set<Review> reviews) {
		this.pictureGroup = pictureGroup;
		this.uploadTime = uploadTime;
		this.reviewTimes = reviewTimes;
		this.visitTimes = visitTimes;
		this.pictureAddress = pictureAddress;
		this.isReview = isReview;
		this.isPublic = isPublic;
		this.lastReviewTime = lastReviewTime;
		//this.pictureVisitLogs = pictureVisitLogs;
		this.ownerId = ownerId;
		this.reviews = reviews;
		this.pictureState = pictureState;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "picture_id", unique = true, nullable = false)
	public Integer getPictureId() {
		return this.pictureId;
	}

	public void setPictureId(Integer pictureId) {
		this.pictureId = pictureId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "picture_group_id")
	public PictureGroup getPictureGroup() {
		return this.pictureGroup;
	}

	public void setPictureGroup(PictureGroup pictureGroup) {
		this.pictureGroup = pictureGroup;
	}

	@Column(name = "upload_time", length = 10)
	public Date getUploadTime() {
		return this.uploadTime;
	}

	public void setUploadTime(Date uploadTime) {
		this.uploadTime = uploadTime;
	}

	@Column(name = "review_times")
	public Integer getReviewTimes() {
		return this.reviewTimes;
	}

	public void setReviewTimes(Integer reviewTimes) {
		this.reviewTimes = reviewTimes;
	}

	@Column(name = "visit_times")
	public Integer getVisitTimes() {
		return this.visitTimes;
	}

	public void setVisitTimes(Integer visitTimes) {
		this.visitTimes = visitTimes;
	}

	@Column(name = "picture_address", length = 500)
	public String getPictureAddress() {
		return this.pictureAddress;
	}

	public void setPictureAddress(String pictureAddress) {
		this.pictureAddress = pictureAddress;
	}

	@Column(name = "is_review")
	public Boolean getIsReview() {
		return this.isReview;
	}

	public void setIsReview(Boolean isReview) {
		this.isReview = isReview;
	}

	@Column(name = "is_public")
	public Boolean getIsPublic() {
		return this.isPublic;
	}

	public void setIsPublic(Boolean isPublic) {
		this.isPublic = isPublic;
	}
	@Column(name = "last_review_time")
	public Date getLastReviewTime() {
		return lastReviewTime;
	}

	public void setLastReviewTime(Date lastReviewTime) {
		this.lastReviewTime = lastReviewTime;
	}

	/*@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "picture")
	public Set<PictureVisitLog> getPictureVisitLogs() {
		return this.pictureVisitLogs;
	}

	public void setPictureVisitLogs(Set<PictureVisitLog> pictureVisitLogs) {
		this.pictureVisitLogs = pictureVisitLogs;
	}*/
	@Column(name = "owner_id")
	public Integer getOwnerId() {
		return ownerId;
	}

	public void setOwnerId(Integer ownerId) {
		this.ownerId = ownerId;
	}
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "picture")
	public Set<Review> getReviews() {
		return this.reviews;
	}

	public void setReviews(Set<Review> reviews) {
		this.reviews = reviews;
	}
	@Column(name = "picture_state")
	public Boolean getPictureState() {
		return pictureState;
	}

	public void setPictureState(Boolean pictureState) {
		this.pictureState = pictureState;
	}

}